﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;
using T.FAS.Runtime.Base.Service;
using T.FAS.Runtime.Base.SGSPI;
using T.ServiceComponent.Kernel.Service;

namespace T.FAS.Runtime.Base.SGPlugin
{
    [SGService]
    public class FASAuthSGService : IFASAuthService
    {
        private readonly FASAuthService _service = new FASAuthService();

        public bool AuthUser(string filter)
        {
            var queryParam = JsonConvert.DeserializeObject<AuthServiceParam>(filter);
            return _service.AuthUser(queryParam);
        }

        public void BatchCreateFASAuthResults(List<FASAuthResult> authResult)
        {
            _service.BatchCreateFASAuthResults(authResult);
        }

        public void DeleteFASAuthResultByFilter(string filter)
        {
            var queryParam = JsonConvert.DeserializeObject<AuthServiceParam>(filter);
            _service.DeleteFASAuthResultByFilter(queryParam);
        }

        public List<FASAuthResult> GetFASAuthResultByFilter(string filter)
        {
            var queryParam = JsonConvert.DeserializeObject<AuthServiceParam>(filter);
            return _service.GetFASAuthResultByFilter(queryParam);
        }
    }
}
